find characteristic equation of a matrix